Fixed bug in prefix assignmnet algorithm