used time class and code optimised