Tidied up code to have working version with setting background colour to white by default