Rework the code and add support for vertical scrolling