upgraded core logic and changed to use pld instead of defrel