revised some of the rotation logic. fixed rotation_required bug. renamed some variables