added rotate mode (mode = 5)