layout changes and refactored some controller code