added my own solution with reflection