Updated code after feedback.