more clever jquery style method for finding minimum.  also refactored to make it callable.