split functions and make it more OOP-style