Final phase 1
with removed errors of R register (fill memory problem)