using State instead of Maybe.
updating doc.
refining comment.