not working... halfdone attempt at factorising
working but defactored