fixed bugs with orientation changing