fixed wrong logic