Using promise to handle array