Improved logic, removed faulty alertview