Add helper functions and remove magic numbers in inline.js