Fixed performance by using a two pass approach