code refactor and adding support for privacy