added inner foreach for echoing array