Maybe two separate functions would be better?