refactor back to a working state, look into async.series to avoid callback hell