made method protected so it cannot be called arbitrarily with random chars and so cause errors
fixed problem which came from casting longs to ints
fixed call to comparator
added space for clarity
add brackets for readability