Handles result code