Define function properly