Small change, this line could be written more efficiently as:
`location = location[:-1]`