Added a flag to select the orientation