Separate views and controllers and clean up codes