add lib graphics
Refactor to new code style