improved logic and done some variants