added profiling logic - charPosToLine is slow