added toCode functions