Updated code

tested code on live database and made bug fixes
Merge branch 'master' of https://github.com/SwithinCush/pcspm