Updated code from reviews