LPS-43148 SF - move variables to where they are used