added rotation detection (hopefully)