Fixed deletion bug with min function