Wrote code for demap and check