rewrite functions

add private variables