better code snippet