update: changed whole code, to add more features.