fixed a few js bugs