refactored after implementing resize change