Hopefully fixed undefined by changing code initializing order.