adds to_hash method to state