defining variables and functions...gets kind of messy due to state management