refactor JS, fix CSS