Updated code to match code in video