Fixed cropping function