working version with mprime instructions