refactor scripts and markup