Final version. Now with database!