moved type coercion to anonymous function