few lines added to code. Also found mistake in receiving data. Not tested yet.