Fixing some logic in our JS functions.