added initial main loop