fixed a bug with an extraneous variable