Refactor functions clean and update.