hopefully fixed an error with exits
removed lines of code which are not needed
removed some variables which don't need to be there