Now using contracts instead of if-then-throw