Implementation of Promises/A+ design pattern