update sam's code .....