Move UpdateUserId to separate query function