Converted Queue to closure based implementation