added dynamic switching between horiz and vert