On the existence of solutions for nonlocal boundary value problems