add errors and some cleaning