cleanup
re-structured code