change selection retrieval into an anonymous function