trying to simplify and generalize