Updated code according to feedback