refactor resize directive