fixed the mining loop
not (much) tested yet, experimental, use on your own risk ;)