fixes sum calculation