move state-related functions and fields to separate class