now with both valid and invalid check