fixed a logic error in the JS