hopefully fixed keymember function