improving functional implementations