Extracted and separated the different functionality in preparation for milestone #1