added a warning message and fixed a function call