fix illegalstate exception