Fixed bugs completed functions