converted pieview into a fragment and cleaned up code