fix bug where max method was actually returning the min