refactor erro listener and clean up grammar