adding emacs client script
refactoring and refining code