fixed my awful js bugs