moved state change from controllers to service
cleaned code