using local variables instead of global ones