Formatting fixed, some function got out of closure