added timeout to receive function