switched defined attribute check to for..in