Refactor, main function, validator, scoring functions