implemented some rudimentary flow control