Fix code according to comments