fixing usage of promises