Created a closure for the process function