rearranging code to support changing y axis