if you add ``.rstrip('/')`` to the end, you can ditch the next two lines. Same in other parts of this function.