fixes bug in json encoding for returns