reorganize paint method, added method headers and comments