min/max calculations added