refactor ugly state switch for quad direction