Updated implementation to handle nonzero mins