Refactoring reduntant int length variables