Updated code to spec.