making before logic run only once