fixing shortly algorithm to ensure uniqueness