found a solution to 005. It is highly not optimized at the current time