implements everything but the line drawing