equalise histogram, tidy into functions