factoring code into different files and created templates. application not working!