Updated js to display checkbox at correct times