Moved part search to its own function