function decorator to check type