Optimized detailView code