Corrected assign function & added testing code