Better implementation of 08 problem solution