slightly improved assignment_to_string function