change logic + added comments