fixed issue with ordering so that .done() is not called before it's actually successful