fixing min collision bug
cleanup code