Solves Problem 7
Makes code cleaner
Encapsulates  function