refactored horiztonal and vertical cover search