clean up, replace var with let, use Dictionary instead of NSDictionary