Added error checking and new vector functions