working getstr function in loop.