need to split the functions up into smaller ones