changed code so it roughly works with the drawing