Addjusted code as discussed today in class