decoding implemented; needs testing and debugging