refactor validation function
Modified validation and convert function