Added special line mask case and refactored some code