Fixed bug with throwing exception