A bit of refactoring for apply_ck