OPT: Made the following changes
1. Replaced np.allclose and np.sign with non-array implementations