Solved bug on refresh, was changing the value of switch