modified code to use new validation