renamed some function + more explicit failwith