Fixed order of bitwise operation
Changed api naming and code structure