tweak to work on scipy sparse