Completed program, added comments, fixed error discovery when using dictionaries