added some min-max stuff