refactor some more code