finished basic algorithm :bear: