Update for speed issues and error catching