added solution with reflection