Error checking and remove detail java