remvoed useless mutex and reorganized sensor repeat code