adding error checking etc.
removed script