Removed all logic from the render code and put it in a tick() method