added orientation detection and printout