Update prefx.cpp

Optimization code