re-factored code and html a  little