updated the code snippet