Coded function

Coded the function