A simple implementation of Promises