Add support to bool type

Add the bool support to the get function
Simplify the code

Simplify the code as @SpecLad suggested.
Change again.

Opps.
Merge pull request #2098 from pxli168:patch-1