Added better usage of promises