Added checking for new version.
Code refactoring