adding my solution with reflection