master code updated

local working and tested