fixed empty result set errors in refresh_messages