Completed receiver code