more funcs, fixed bugs