Added updated resize function