vertical and horizontal case1 working