added funcs and fixed bugs
small changes