fix a bug on program
add emacs mode and error handling at top level