updated the code and put in a more complete example
updated the code and put in a more complete example