a bug fixed in a ridiculous way by adding a flush...and some minor change