added error prevention code