added some constraints to stop oscillations