trying to solve the most general case