rotation logic