Copied function to prevent undefined reference error