Streamline the code of predictBeanType