refactor stash drawing code