finished writing while() simulator