Fix the bug that return nil value in scan return ...

And modified calculation for measuring the distance of rows and columns in find_marks_grid