Updated the code to adjust positioning based on text size