throw error on failure
move inline function to its definition