added solution algoritm