optimized implemention of queue enqueue