Attemps to optimize slow solution