Javascript refined