Refactored code to be more clean. Need to switch to postgresql to allow for distinct columns.