code refactored in search graph