Added types to methods and defined lastButOne