Code shortened, added some messages