correct horizontal distance calculation & tipos
typos and improvement