A closed form solution of the two body problem in non-inertial reference frames