wtf res is not defined?