modified javascript classic blog answer