fixes error in lastResult variable