fixes to object() function crashing