updated code for PN
merged and updated