changed name of _encode_data to _prepare_data since that better describes it