Error handling for some of the functions