added func-ty & fixed bugs in some functions