refactored container and centralized type checks