optimized changes orientation, fix bugs