Is there a better way to create something like object?