added check for whitespaces in key