fixing minor errors e.g. redefined variable