var ObjectID = require('../').ObjectID;

module.exports = function find_options(args) {
  if(!args) args = [];
  var signature = Array.prototype.map.call(args, function(arg){ return Array.isArray(arg)? "array" : typeof arg }).join();
  var options = {
    query: args[0],
    fields: args[1],
    skip: 0,
    limit: 0,
    callback: /function$/.test(signature)? args[args.length-1] : undefined
  };
  switch(signature) {
    //callback?
    case "":
    case "undefined":
    case "function":
      options.query = {};
      options.fields = {};
      break;
    //selector, callback?,
    case "object":
    case "object,function":
      options.fields = {};
      if (ObjectID.isValid(options.query))
        options.query = { _id: options.query };
      break;
    //selector, fields, callback?
    //selector, options, callback?
    case "object,object":
    case "object,undefined,function":
    case "object,object,function":
      //sniff for a 1 or -1 to detect fields object
      if(!args[1] || Math.abs(args[1][0])===1) {
        options.fields = args[1];
      }
      else {
        if(args[1].skip) options.skip = args[1].skip;
        if(args[1].limit) options.limit = args[1].limit;
        if(args[1].fields) options.fields = args[1].fields;
        if(args[1].projection) options.fields = args[1].projection;
      }
      break;
    //selector, fields, options, callback?
    case "object,object,object":
    case "object,object,object,function":
      if(args[2].skip) options.skip = args[2].skip;
      if(args[2].limit) options.limit = args[2].limit;
      if(args[2].fields) options.fields = args[2].fields;
      if(args[2].projection) options.fields = args[2].projection;
      break;
    //selector, fields, skip, limit, timeout, callback?
    case "object,object,number,number,number":
    case "object,object,number,number,number,function":
      options.timeout = args[4];
    //selector, fields, skip, limit, callback?
    case "object,object,number,number":
    case "object,object,number,number,function":
      options.skip = args[2];
      options.limit = args[3];
      //if(typeof args[4]==="number") options.timeout = args[4];
      break;
    default:
      throw new Error("unknown signature: "+ signature);
  }
  return options;
}

@@ -277,23 +277,18 @@
 fields: 
-args%5B1%5D
+%7B%7D
 ,%0A    sk
@@ -512,35 +512,8 @@
 %7B%7D;%0A
-      options.fields = %7B%7D;%0A
     
@@ -599,35 +599,8 @@
 n%22:%0A
-      options.fields = %7B%7D;%0A
     
@@ -1393,32 +1393,64 @@
 ject,function%22:%0A
+      options.fields = args%5B1%5D;%0A
       if(args%5B2%5D
@@ -1828,32 +1828,64 @@
 mber,function%22:%0A
+      options.fields = args%5B1%5D;%0A
       options.ti
@@ -1980,32 +1980,32 @@
 number,number%22:%0A
-
     case %22object
@@ -2029,32 +2029,64 @@
 mber,function%22:%0A
+      options.fields = args%5B1%5D;%0A
       options.sk

Fix false positive fields options