Defined my functions and added other helper functions