Changed the InvalidStateException to IllegalStateException