added header and separated program into modules