Update code to reflect @OJ code suggestions