I think this code for splitting the path would be better off in its own function.