src: refractoring and bug with orientation fixed