Added timing for speed optimization