changed replacements to functions

Changed replacements to functions so not everything would have to be
calculated every time.