can you pull this out into it's own function?