moved sensor updating and printing to functions