refactor to closure instead objects