fixed perfomance of solution 12