Working solution. needs to replace of with other looping mech