added ajax loader, modified state machine