restored rotation function