some refactoring has been used and other changes has been done