updated with some code correction