refactored to get rid of resolve