diff --git a/nodequeue_randomizer.jobqueue.inc b/nodequeue_randomizer.jobqueue.inc
index 91be0cc..601152d 100644
--- a/nodequeue_randomizer.jobqueue.inc
+++ b/nodequeue_randomizer.jobqueue.inc
@@ -16,18 +16,18 @@
  * @param $period
  *   Integer value representing the period between randomizations in seconds
  */
-function nodequeue_randomizer_randomize_queue($sqid, $last_run, $period) {
-  $results = db_query(
+function nodequeue_randomizer_randomize_queue($item) {
+  $result = db_query(
     "SELECT nid, weight
     FROM {nodequeue_nodes}
-    WHERE sqid = %d",
-    $sqid
+    WHERE sqid = :sqid",
+    array('sqid' => $item['sqid'])
   );
 
   $range = 0;
   $nids = array();
   $end_nids = array(); //Nodes with weight of 0 are set aside and stuck at the back of the queue
-  while ($node_info = db_fetch_object($results)) {
+  foreach ($result as $node_info) {
     if ($node_info->weight) {
       $nids[$node_info->nid] = $node_info->weight;
       $range = $range + $node_info->weight;
@@ -45,9 +45,9 @@ function nodequeue_randomizer_randomize_queue($sqid, $last_run, $period) {
   foreach ($node_list as $nid) {
     db_query(
       "UPDATE {nodequeue_nodes}
-      SET position = %d
-      WHERE sqid = %d AND nid = %d",
-      $position, $sqid, $nid
+      SET position = :position
+      WHERE sqid = :sqid AND nid = :nid",
+      array('position' => $position, 'sqid' => $item['sqid'], 'nid' => $nid)
     );
 
     $position++;
@@ -55,9 +55,9 @@ function nodequeue_randomizer_randomize_queue($sqid, $last_run, $period) {
 
   db_query(
     "UPDATE {nodequeue_randomizer}
-    SET last_run = %d
-    WHERE sqid = %d",
-    $last_run + $period, $sqid
+    SET last_run = :last_run
+    WHERE sqid = :sqid",
+    array('last_run' => $item['last_run'] + $item['period'], 'sqid' => $item['sqid'])
   );
 }
 
diff --git a/nodequeue_randomizer.module b/nodequeue_randomizer.module
index fdf38e3..fb22e74 100644
--- a/nodequeue_randomizer.module
+++ b/nodequeue_randomizer.module
@@ -93,7 +93,7 @@ function nodequeue_randomizer_cron_queue_info() {
  * Implementation of hook_cron().
  */
 function nodequeue_randomizer_cron() {
-  module_load_include('inc', 'nodequeue_randomizer', 'nodequeue_randomizer.cron');
+  module_load_include('inc', 'nodequeue_randomizer', 'nodequeue_randomizer.jobqueue');
 
   $nodequeue_randomizer_queues = nodequeue_randomizer_get_queues();
   $queue = DrupalQueue::get('nodequeue_randomizer');
