improved Code for Cursor