Adding Horizontal and Vertical Orientation Option. Refactoring Code