final version with database done