edited histogram function