Improved algorithm for quantum separability and entanglement detection