infinite loop in nodejs