Refactor more code