finally added file seeking
renamed some variables and other cleanup