Refactor debug view
Avoid logic in ERB and use helpers