new implementation for binary