Refoctor AND Fix to handle unexpected prefix values