Refactor code in projection_line method