pass onTick function to constructor
refactoring