optimize main loop a bit, remove extra print