Add sample, refact error handle