Use Promises instead of code repetition