fixing js bugs