Fix tabulation
Refactor and clean javascript