change assertion into exception (#254)