working on generalizing code