slow version of complete receiver code

NEED OPTIMIZATION