working verison of pocker.c