storing output within result array