Cleaner implementation of a promise