Updated to use spromise instead of jquery promise