Refactor to make it work with the $callback variable