changed the structure to be a bit cleaner