Add key cast
Use parametric Comparable
Use ArrayList
Remove duplication code