reinvented the logic, added some help