Implemented saving events to db