First working version of controller