refactor to move info window outside the loop