fix error in source. Add better error handling.