automatic parameters calculation

automatic parameters calculation added,
also menu logic unified to shrink the code and make it more clear