General implemetation.