moved local vars to solve function from being object members