refactoring and adding a timer and more functionality

refactoring and adding a timer and more functionality

Signed-off-by: riabop <riabop@gmail.com>