Refactored main index