better way of coding