more efficient code and better structure for upcoming change