updated event listener and add pre command