added exception handeling for functions that fail