Solution for basic reduce