updated variable and cleaned up code