Added depth arg
Error check