main file reorganized, and introduced a timer