Updated to use dynamic x values