Implemented while, nicer emit()