This is ugly. Is there no other way to do this?