changed key() algorithm to support integers