Set Interval function in javascript