refactor to deal with changes in swift