works when n is small