modified rfind again