is this sane or is there a better way for this?