Code changes as per comments