Less hacky solution