renamed variables to be more self explanatory, improved split function