fixed so that emit() works