refactor duplicated code in summary and fix class name in js