simplified main loop