Added proper min/maxing