Added timer and some helper functions