changed min dist to 3'

also some refactoring, should test.