made code using promises more concise