more functions and code clean