using queue instead of multiple threads