first implementation of hand() function