minor changes due to errors and incorrect assumptions