Added code from competition.