folds different cases into one function

- cleans up unnecessary code
handles simple prefix case
merges simplest case with simple prefixes case
handles prefix lists

- refactors the whole solution