add main logic functions
add main logic functions