add calculate_two function and fix bugs