Improved check_by_type to make it work!