more idiomatic way to check the end of a string