Added function to prepare the X values mapping them, and fixed a stuck problem