Added new function generate plan