trying to structure code