split functions out into seperate js to avoid duplication