Error handling for some functions done