Getting messed up with objects and arrays