changed logic to try and remedy an error