SOC-3973: Refactor code