working version of merged mining