rewrote get put method use stream and foreach