refactored scheme handling