implementing and testing the `paths` function