Replace throwing if statement with assertion

IMO it is cleaner this way.