fixed code bugs [#ref no ref]