merged assign function with assignment checking -untested-