Some refactoring
More validation checks