please remove unused code but add proper logging in case of an exception