refactoring
reworked as an API wooo!
updated from prefix.cc