Pulled the closure logic to make it non static