clean up code
add master functionalities