Added @Override annotations and simplified a while loop to a for.