javascript redone a bit