Fixed the fitToSize function