Use 'then' instead of 'onSuccess' and 'onError' for promises