Reformatted the code, added timewindow inputbox