refactored code and added cpf namespace use