Updated code based on feedback