rendering histogram and refactored