refactoring added code for user exit
bug fixes