fixed cropping code near edges