refactoring after reviewing Zacs comments