Reduced the number of local variables