checking returned val is dictionary
cleaning up formatting