refactored events persistence