Code refactoring and added new checks