fix error when --mines option used; refactoring