Clean up logic in percentage calculation