updated code snippet