deferred object didn't work, using a global boolean