looping function declaration issues