i got it working but it still needs a lot of optimization.