spinner code with closures