Modify Shell Script and make it smarter