refactor pay