modified some variables to be final