Refactor to avoid session usage