seems like this logic can be simplified right?