encapsulating some new code which can be reused by MemwriteEngine