added anon function and calculation