Michael, added join event database code