Unbound local veriable error fixes