fixed try except finally block