First working version using AppController