implemented scott's changes, fixed error introduced earlier