added check for valid credentials