housekeeping

re-structured code