fixed enqueue function