first draft of written solution done