updated working with database - doesnt work now