Added code for portrait mode