handling all degeneracies except horizontal lines