modularized and completed dot code