Moving setTimeout inside