write a better code