code refactoring and started work on fitToContainer feature