Restructured generate key method (created removeJ() method)