fairly inefficient conversion functions