Tidied up getNextColor function a little bit