splitting onDataReceived() method