added hw3 main loop