Refactor
Going to do something nicer, but at least promises working correctly now