Threshold Based Encoding And Decoding