refactored to use update/draw pattern