fixed some js bugs