Changed to use Angular's defined() method