Updated code as per feedback