work in progress
refactored to promises