cleaned up the tick function a bit