Fixed issue with state() not return the proper value