getEnum method rewritten more effectively