main code fix after code review