Refactoring, added validations