could the function be anon and placed here instead?