mostly written but event emission not working