add xml validation and refactored classes