refactored start line,char finding to a separate function