added maxmin and unit tests