write a database class and change timerEvent class for better use with database