Fixing js bug