code snippet for my exercise