What about moving this code to a function somewhere else?