use closure to fix the type of a key