adding app state and some organization for received messages