Some changes on solution 3 ( not working for the moment) and add a stack
class