Fixed bug in PEC routine