fixed calculation logic