re-structured code