attempt at performance optimization