Some refractoring and finished all the db methods