getting instances from database