adding handling for errors