Deleted fprintf, added check for MIN or MAX first (may be incorrect)