finished js functionality