fix code to match comments