Moved error handling to check_if_keys_provided()