Working code: After little changes