code cleanup, fix try catch