fixed possible reference before assignment bug