Added exception when requestId is not found
reorganized code