To Implement using Protothreads