pass filename in emits
upped version