Moved redundant code from methods to method called calculateHeight