Separated drawing and functional code