trying to simplify into smaller code