Added code for outputting motion data