tried to fix function loop

not working