refactoring findElement method