implements step by step ; some clean