simplified and fixed wrong object bug