improving code for todos