fixed bug in case of peers not found, check again and refactor