fixed divide by 0, added q for quit, strip leading spaces