factored code into axis for axis chapter