added error handling, fixed bad path after calling formula build function