Complete function code

Complete function code