cleaned up traverse with endsWith