making things more efficient, less reliance on global vars