fixed warnings and errors related to scope of variables, parameters should be final