Refactoring error throws and anonymous functions argument