Move fill function out of tools.js