reorganized code to allow for global orientations