Fix IllegalStateException