added basic key validating function