Added timer and improved functionality