Seems a bit hacky. Is there any better way to do this?