Using HashMap now instead of sorting every time