refactor code to enable unit and integration testings and simulation
refactor code to enable unit and integration testings and simulation