implemented first phase of line counting