changed to use functions