added checks for rotation, only applies it if valid