Checking for type when setting value