replaced emit with log function