Cleaning up the paint function.