started working on the general case