movement detection code