soeed related refactor of keyval functions