Refactor: reduce complexity in code.