Fixed bug not returning promise