tidied up momentum code