changes to badge drawing code