Create function DoTick