added debug to pl func