Reworked blpop and brpop