refactored version (EBKAC)