abstracted the rider position variable to the outside of the each function.