completed javascript part