added a simpler version of prefixmin