Updated Code with the help of Ryan Berkey

updated to a better structure