made the code dryer