refactoring and cleaning up layout