fixing maxgap
fixing maxgap
cleanup