refactor and size functionality