Removed global variable j