Refactored title code