add all necessary function, miss the interrupt part