Refactored binary conversion