refactoring miner.c