Refactor to use closure