Why are you using endswith here?