Modified the js to be executed when the condition is true