screwed up the location of the encode call in hash, resulting in attributeerror. Fixed