added some functions to clean up how the code works a little bit, not strictly necessary but better in my mind