some pretty terrible javascript