I just removed ~20 lines by using $direction