The latest functionality with a test function for checking correctness