bug fix - added short circuit simplification statements at the end of while body