Refactor ugly methods for searching for locations in legs

This commit fixes #14. Big thanks to @mjezzi for showing me how to do this! :thumbsup: