Fixed typo in toCode function