conerted this to some horrible js object scheme hack