Refactor: get rid of endsWith()