finished validator code