moved two functions up into module