Building more functions in the code for better structure