moved type conversion code from runtime to frontend