removed unused include, renamed function, moved comment
error checking