modified layout and organized view functions to pass locals() to template