Cleaned up type checking