Merged the replstate update code
Removed console printout statements