refactoring some functions! TNX voku for your great job!