Refactor to make code cleaner.