refactor to closure