implement of http://xrath.com/2012/05/time-management-based-on-stack/