Improve enqueue functions with a check for redundancy and dependency