Added timer and changed database query