"Undefined" error fixed