Added controller and refactored UI layer