fixed divide by zero, added more (untested) environments