changed many of the vars to function calls