separated controllers and fixed the statechange queries