updated from Coursera version to my version
updated with my code and comments