Added a distance variable for easier modification and tweaking of code