Eror checking added