fix: return 0 instead of undefined for cost calculation

Closes #24