making SOS a bit more generic

still needs a lot of optimisation