copied the assignment 2 sample code. Its hard to understand what it does our why we need <<- for scopes to work correctly