created functions working with database