tried moving variables out of cuntion - maybe scope issue - not working