Make this all slightly more type safe